debug!("manifest has no build targets");
}
+ if let Err(e) = unique_build_targets(&targets, layout) {
+ bail!("duplicate build target found: `{}`", e);
+ }
+
let mut deps = Vec::new();
let replace;
Ok(())
}
+/// Will check a list of build targets, and make sure the target names are unique within a vector.
+/// If not, the name of the offending build target is returned.
+fn unique_build_targets(targets: &[Target], layout: &Layout) -> Result<(), String> {
+ let mut seen = HashSet::new();
+ for v in targets.iter().map(|e| layout.root.join(e.src_path())) {
+ if !seen.insert(v.clone()) {
+ return Err(v.display().to_string());
+ }
+ }
+ Ok(())
+}
+
impl TomlDependency {
fn to_dependency(&self,
name: &str,
src[..]Cargo.toml:1:5-1:6 expected a value\n\n"))
}
+#[test]
+fn cargo_compile_duplicate_build_targets() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [lib]
+ name = "main"
+ crate-type = ["dylib"]
+
+ [dependencies]
+ "#)
+ .file("src/main.rs", r#"
+ fn main() {}
+ "#);
+
+ let error_message = format!("\
+[ERROR] failed to parse manifest at `[..]`
+
+Caused by:
+ duplicate build target found: `{}`",
+ p.root().join("src[..]main.rs").display());
+
+ assert_that(p.cargo_process("build"),
+ execs()
+ .with_status(101)
+ .with_stderr(error_message)
+ )
+}
+
#[test]
fn cargo_compile_with_invalid_version() {
let p = project("foo")